package com.weijin.bookborrowmanagesystem.mapper;

import com.weijin.bookborrowmanagesystem.enums.BookEnum;
import com.weijin.bookborrowmanagesystem.pojo.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author WeiJin
 * @Version 1.0
 * @Date 2025/3/13 10:22
 */
@Mapper
public interface BookMapper {
    @Insert("insert into t_book(title,author,stock) values (#{title},#{author},#{stock})")
    int insert(Book book);

    @Select("select * from t_book")
    List<Book> selectAll();

    @Select("select * from t_book where id = #{id}")
    Book selectById(@Param("id") int id);

    @Update("update t_book set stock = #{stock} where id = #{id}")
    int updateStockById(Integer id, Integer stock);

    @Update("update t_book set status = #{status} where id = #{id}")
    int updateStatus(Integer id, BookEnum status);
}
